home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part2 / 12494 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.2 KB

  1. Path: skivs.ski.org!usenet
  2. From: gt@ns.oon.or.jp (Gemini Thunder)
  3. Newsgroups: comp.lang.c
  4. Subject: RAND_MAX
  5. Date: Mon, 01 Apr 1996 05:55:01 GMT
  6. Organization: Smith-Kettlewell Eye Research Institute
  7. Message-ID: <4jnr55$e6l@skivs.ski.org>
  8. NNTP-Posting-Host: 143.45.100.64
  9. X-Newsreader: Forte Free Agent 1.0.82
  10.  
  11. I have a (stupid) question / observation about RAND_MAX.
  12.  
  13. K&R2 says:
  14.   "rand returns a a pseudo-random integer in the range 0 to RAND_MAX,
  15. which is at least 32767"
  16.  
  17. It looks like RAND_MAX is not required to be the same as any other
  18. limit (such as MAX_INT, etc.), that is fine, but why?  
  19. Wouldn't it be easier if RAND_MAX == MAX_INT or some other value?  
  20.  
  21. The reason I say this is how can you be sure your array will hold a
  22. RAND_MAX sized integer, without some checking before hand, if RAND_MAX
  23. is out there doing its own thing?
  24.  
  25. Or does ANSI pin it down (in which case why have a RAND_MAX #defined),
  26. or am I just worked up over nothing and overlooking something obvious?
  27.  
  28. Please Email me in reply, so I can turn this in as homework, since my
  29. time is too precious to read this newsgroup for answers I can't figure
  30. out on my own. <that was supposed to be sarcastic>   
  31.   
  32.  
  33.